package de.koller.libration.layer;

import de.koller.aframe.util.misc.BufferedRandomFloat;
import de.koller.aframe.util.noise.n2D.ScrollingPerlin2D;
import de.koller.libration.display.LDisplay;
import java.util.Random;

public class PixelDistLayer extends LDisplay {
	private final Random rnd = new Random();
	private final BufferedRandomFloat crnd = new BufferedRandomFloat( "./temp/PixDistLayer" + toString(), rnd );
	private final ScrollingPerlin2D perlin = new ScrollingPerlin2D( crnd, 7, .8f );

	public PixelDistLayer() {
		super( 600, 600 );
		//perlin.normalizeMaxBound( Perlin2D.maxHeight( 0, 6, .7f ) );
		
		for( int x = 0; x < this.raster.getWidth(); x++ )
			for( int y = 0; y < this.raster.getHeight(); y++ ) {
				float f = perlin.getValue( 1f / this.raster.getWidth() * x, 
										   1f / this.raster.getHeight() * y );
				
				double j = ( .5d * (f - .3) );
				if( j < 0 ) j = 0;
				boolean k = rnd.nextDouble() * j > .8;
				int c = k ? 0xff_ffffff : 0xff_000000;
				//int c = ColorGradient.cubic( f, 0xffffffff, 0xff000000 );
				this.raster.setPixel( c, x, y );
			}
				
	}

}
